﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AddressBook.Master" AutoEventWireup="true" CodeBehind="ManageFamilies.aspx.cs" Inherits="AddressBook.Web.ManageFamilies" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContentPlaceHolder" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainPaneContentPlaceHolder" runat="server">
	<table border="0" cellpadding="0" cellspacing="0" style="width: 674px; margin: 0px auto;">
		<tr>
			<td valign="top">
				<div class="FamilyList">
					<div class="ListHeader">
						Familes
						<div style="float: right;">
							<asp:ImageButton ID="FamilyListAddFamilyButton" runat="server" ImageUrl="~/Images/add_16.png" AlternateText="Add Family" ToolTip="Add Family" />
						</div>
					</div>
					<asp:ListView ID="ManageFamiliesFamilyList" runat="server" 
												OnItemCommand="ManageFamiliesFamilyList_ItemCommand" 
												OnItemEditing="ManageFamiliesFamilyList_ItemEditing" 
												OnItemDeleting="ManageFamiliesFamilyList_ItemDeleting" >
						<LayoutTemplate>
							<ul style="list-style-image: none; list-style-type: none; width: 300px; padding-left: 0px; margin: 0px;">
								<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
							</ul>
						</LayoutTemplate>
						<ItemTemplate>
							<li style="padding: 4px 4px; line-height: 16px;">
								<asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/edit_family_16.png" AlternateText="Open Family" ToolTip="Open Family" ImageAlign="Bottom" />
								<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Delete Family" ToolTip="Delete Family" ImageAlign="Bottom" />
								<asp:Literal ID="FamilyName" runat="server" Text='<%# Eval("Name") %>' />
								<cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																					 ConfirmText="Are you sure you want to delete this family?" 
																					 TargetControlID="DeleteButton" />
							</li>
						</ItemTemplate>
						<AlternatingItemTemplate>
							<li style="background-color: #BCDFF2; padding: 4px 4px; line-height: 16px;">
								<asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/edit_family_16.png" AlternateText="Open Family" ToolTip="Open Family" />
								<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Delete Family" ToolTip="Delete Family" />
								<asp:Literal ID="FamilyName" runat="server" Text='<%# Eval("Name") %>' />
								<cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																					 ConfirmText="Are you sure you want to delete this family?" 
																					 TargetControlID="DeleteButton" />
							</li>
						</AlternatingItemTemplate>
						<EmptyDataTemplate>
							<asp:Literal ID="EmptyList" runat="server" Text="You have not yet created any families" />
						</EmptyDataTemplate>
					</asp:ListView>
				</div>
			</td>
			<td valign="top">
				<asp:Panel ID="EditFamilyDetailsPanel" runat="server" Visible="false" CssClass="Family">
				  <div class="FamilyDetails">
					  <div class="SubHeader">
						  Family Details
						  <div style="float: right">
								<asp:ImageButton ID="EditFamilyDetailsButton" runat="server" ImageUrl="~/Images/edit_family_16.png" AlternateText="Edit Details" ToolTip="Edit Details" OnClick="EditFamilyDetailsButton_Click" />
								<asp:ImageButton ID="EditFamilyPanelCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" OnClick="EditFamilyCloseButton_Click" />
						  </div>
				    </div>
				    <div style="margin: 8px;">
				      <asp:HiddenField ID="EditFamilyIdField" runat="server" />
				      <asp:Literal ID="EditFamilyNameLiteral" runat="server" />
				      <br /><br />
					    <asp:Literal ID="EditFamilyAddressLiteral" runat="server" />
					  </div>
					</div>
					<div class="FamilyMembers">
					  <div class="SubHeader">
					    Family Members
					    <div style="float: right;">
							  <asp:ImageButton ID="FamilyMembersAddButton" runat="server" ImageUrl="~/Images/add_16.png" AlternateText="Add Family Member" ToolTip="Add Family Member" />
						  </div>
					  </div>
					  <asp:ListView ID="EditFamilyMembersList" runat="server" 
													OnItemCommand="EditFamilyMembersList_ItemCommand" 
													OnItemDeleting="EditFamilyMembersList_ItemDeleting">
						  <LayoutTemplate>
							  <ul style="list-style-image: none; list-style-type: none; width: 354px; padding-left: 0px; margin: 0px;">
								  <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
							  </ul>
						  </LayoutTemplate>
						  <ItemTemplate>
							  <li style="padding: 4px 4px; line-height: 16px;">
									<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("ContactId") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Remove Family Member" ToolTip="Remove Family Member" />
							    <asp:Literal ID="ContactNameLiteral" runat="server" Text='<%# Eval("FullName") %>' />
							    <cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																					 ConfirmText="Are you sure you want to delete this family member?" 
																					 TargetControlID="DeleteButton" />
							  </li>
						  </ItemTemplate>
						  <AlternatingItemTemplate>
							  <li style="background-color: #BCDFF2; padding: 4px 4px; line-height: 16px;">
									<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("ContactId") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Remove Family Member" ToolTip="Remove Family Member" />
							    <asp:Literal ID="ContactNameLiteral" runat="server" Text='<%# Eval("FullName") %>' />
							    <cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																						 ConfirmText="Are you sure you want to delete this family member?" 
																						 TargetControlID="DeleteButton" />
							  </li>
						  </AlternatingItemTemplate>
						  <EmptyDataTemplate>
  							
						  </EmptyDataTemplate>
					  </asp:ListView>
					</div>
				</asp:Panel>
			</td>
		</tr>
	</table>
	
	<!--Add Family Popup Panel-->
	<cc1:ModalPopupExtender ID="AddFamilyPanelPopupExtender" runat="server" 
													TargetControlID="FamilyListAddFamilyButton" 
													PopupControlID="ManageFamiliesAddFamilyPanel" 
													CancelControlID="AddFamilyCloseButton" 
													BackgroundCssClass="modalBackground" />
  <asp:Panel ID="ManageFamiliesAddFamilyPanel" runat="server" CssClass="PopupPanel" style="display: none;" > 
		<div class="PopupHeader">
			Add Family
			<div style="float: right">
				<asp:ImageButton ID="AddFamilySaveButton" runat="server" ImageUrl="~/Images/save_16.png" AlternateText="Save Family" ToolTip="Save Family" OnClick="AddFamilySaveButton_Click" ValidationGroup="AddFamily" style="margin-right: 4px;" />
			  <asp:ImageButton ID="AddFamilyCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" />
			</div>
		</div> 
    <table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2"><asp:ValidationSummary ID="AddFamilyValidationSummary" runat="server" ValidationGroup="AddFamily" /></td>
			</tr>
      <tr>
        <td><asp:Literal ID="AddFamilyNameLiteral" runat="server" Text="Name" /></td>
        <td>
          <asp:TextBox ID="AddFamilyNameTextBox" runat="server" MaxLength="50" />
          <asp:RequiredFieldValidator ID="AddFamilyNameRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a family name" 
																			ControlToValidate="AddFamilyNameTextBox"
																			Display="None" 
																			ValidationGroup="AddFamily" />
        </td>
      </tr>
      <tr>
				<td colspan="2">
					<asp:CheckBox ID="AddAddressFromExisting" runat="server" Text="From Existing" OnCheckedChanged="AddAddressFromExisting_CheckedChanged" AutoPostBack="true" />
				</td>
      </tr>
      <tr>
				<td colspan="2" style="padding-bottom: 10px;">
					<asp:DropDownList ID="AddAddressExistingDropDown" runat="server" Enabled="false" OnSelectedIndexChanged="AddAddressExistingDropDown_SelectedIndexChanged" AutoPostBack="true" Width="200px" Visible="false" />
				</td>
			</tr>
      <tr>
        <td><asp:Literal ID="AddFamilyAddressLine1Literal" runat="server" Text="Street Address" /></td>
        <td>
          <asp:TextBox ID="AddFamilyAddressLine1TextBox" runat="server" MaxLength="60" />
          <asp:RequiredFieldValidator ID="AddFamilyAddressLine1RequiredValidator" runat="server" 
																			ErrorMessage="You must enter a street name" 
																			ControlToValidate="AddFamilyAddressLine1TextBox" 
																			Display="None" 
																			ValidationGroup="AddFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddFamilyAddressLine2Literal" runat="server" Text="Appt #" /></td>
        <td>
          <asp:TextBox ID="AddFamilyAddressLine2TextBox" runat="server" MaxLength="60" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddFamilyCityLiteral" runat="server" Text="City" /></td>
        <td>
          <asp:TextBox ID="AddFamilyCityTextBox" runat="server" MaxLength="30" />
          <asp:RequiredFieldValidator ID="AddFamilyCityRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a city" 
																			ControlToValidate="AddFamilyCityTextBox" 
																			Display="None" 
																			ValidationGroup="AddFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddFamilyStateLiteral" runat="server" Text="State" /></td>
        <td>
          <asp:DropDownList ID="AddFamilyStateDropDown" runat="server" />
          <asp:RequiredFieldValidator ID="AddFamilyStateRequiredValidator" runat="server" 
																			ErrorMessage="You must select a state" 
																			ControlToValidate="AddFamilyStateDropDown" 
																			Display="None" 
																			ValidationGroup="AddFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddFamilyPostalCodeLiteral" runat="server" Text="Zip Code" /></td>
        <td>
          <asp:TextBox ID="AddFamilyPostalCodeTextBox" runat="server" MaxLength="5" />
          <asp:RequiredFieldValidator ID="AddFamilyPostalCodeRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a zip code" 
																			ControlToValidate="AddFamilyPostalCodeTextBox" 
																			Display="None" 
																			ValidationGroup="AddFamily" />
        </td>
      </tr>
    </table>
  </asp:Panel>
  
  <!--Edit Family Popup Panel-->
	<cc1:ModalPopupExtender ID="EditFamilyPanelPopupExtender" runat="server" 
													TargetControlID="HiddenAction" 
												  PopupControlID="EditFamilyPanel" 
													CancelControlID="EditFamilyCloseButton" 
													BackgroundCssClass="modalBackground" />
	<asp:LinkButton ID="HiddenAction" runat="server" style="visibility: hidden;" />
  <asp:Panel ID="EditFamilyPanel" runat="server" CssClass="PopupPanel" style="display: none;" > 
		<div class="PopupHeader">
			Edit Family
			<div style="float: right">
				<asp:ImageButton ID="EditFamilySaveButton" runat="server" ImageUrl="~/Images/save_16.png" AlternateText="Save Family" ToolTip="Save Family" OnClick="EditFamilySaveButton_Click" ValidationGroup="EditFamily" style="margin-right: 4px;" />
			  <asp:ImageButton ID="EditFamilyCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" />
			</div>
		</div> 
    <table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2"><asp:ValidationSummary ID="EditFamilyValidationSummary" runat="server" ValidationGroup="EditFamily" /></td>
			</tr>
      <tr>
        <td><asp:Literal ID="EditFamilyPopupNameLiteral" runat="server" Text="Name" /></td>
        <td>
          <asp:TextBox ID="EditFamilyNameTextBox" runat="server" MaxLength="50" />
          <asp:RequiredFieldValidator ID="EditFamilyNameRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a family name" 
																			ControlToValidate="EditFamilyNameTextBox"
																			Display="None" 
																			ValidationGroup="EditFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditFamilyAddress1Literal" runat="server" Text="Street Address" /></td>
        <td>
          <asp:TextBox ID="EditFamilyAddress1TextBox" runat="server" MaxLength="60" />
          <asp:RequiredFieldValidator ID="EditFamilyAddress1RequiredValidator" runat="server" 
																			ErrorMessage="You must enter a street name" 
																			ControlToValidate="EditFamilyAddress1TextBox" 
																			Display="None" 
																			ValidationGroup="EditFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditFamilyAddress2Literal" runat="server" Text="Appt #" /></td>
        <td>
          <asp:TextBox ID="EditFamilyAddress2TextBox" runat="server" MaxLength="60" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditFamilyCityLiteral" runat="server" Text="City" /></td>
        <td>
          <asp:TextBox ID="EditFamilyCityTextBox" runat="server" MaxLength="30" />
          <asp:RequiredFieldValidator ID="EditFamilyCityRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a city" 
																			ControlToValidate="EditFamilyCityTextBox" 
																			Display="None" 
																			ValidationGroup="EditFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditFamilyStateLiteral" runat="server" Text="State" /></td>
        <td>
          <asp:DropDownList ID="EditFamilyStateDropDown" runat="server" />
          <asp:RequiredFieldValidator ID="EditFamilyStateRequiredValidator" runat="server" 
																			ErrorMessage="You must select a state" 
																			ControlToValidate="EditFamilyStateDropDown" 
																			Display="None" 
																			ValidationGroup="EditFamily" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditFamilyPostalCodeLiteral" runat="server" Text="Zip Code" /></td>
        <td>
          <asp:TextBox ID="EditFamilyPostalCodeTextBox" runat="server" MaxLength="5" />
          <asp:RequiredFieldValidator ID="EditFamilyPostalCodeRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a zip code" 
																			ControlToValidate="EditFamilyPostalCodeTextBox" 
																			Display="None" 
																			ValidationGroup="EditFamily" />
        </td>
      </tr>
    </table>
  </asp:Panel>
  
  <!--Add Family Member Popup-->
  <cc1:ModalPopupExtender ID="AddFamilyMemberPanelPopupExtender" runat="server" 
													TargetControlID="FamilyMembersAddButton" 
													PopupControlID="AddFamilyMemberPanel" 
													CancelControlID="AddFamilyMemberCloseButton" 
													BackgroundCssClass="modalBackground" />
  <asp:Panel ID="AddFamilyMemberPanel" runat="server" CssClass="PopupPanel" style="display: none;">
    <div class="PopupHeader">
			Add Family Member
			<div style="float: right">
				<asp:ImageButton ID="AddFamilyMemberSaveButton" runat="server" ImageUrl="~/Images/save_16.png" AlternateText="Save Family" ToolTip="Save Family" OnClick="AddFamilyMemberSaveButton_Click" ValidationGroup="AddFamilyMember" style="margin-right: 4px;" />
			  <asp:ImageButton ID="AddFamilyMemberCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" />
			</div>
		</div>
    <cc1:ListSearchExtender ID="ContactListBoxSearchExtender" runat="server" 
                            TargetControlID="ContactListBox" 
                            PromptPosition="Top" 
                            PromptText="Type to search" 
                            IsSorted="true" 
                            QueryPattern="StartsWith" />
    <asp:ListBox ID="ContactListBox" runat="server" SelectionMode="Multiple" style="width: 250px; height: 300px; margin-top: 16px; border: none 0px; border-top: solid 1px #000000;" />
  </asp:Panel>
</asp:Content>
